package cn.tedu.tmall.admin.content.service.impl;

import cn.tedu.tmall.admin.content.dao.persist.repository.IArticleRepository;
import cn.tedu.tmall.admin.content.dao.persist.repository.ICategoryRepository;
import cn.tedu.tmall.admin.content.pojo.entity.Article;
import cn.tedu.tmall.admin.content.pojo.entity.Category;
import cn.tedu.tmall.admin.content.pojo.parm.ArticleAddNewParm;
import cn.tedu.tmall.admin.content.pojo.parm.CategoryAddNewParm;
import cn.tedu.tmall.admin.content.service.IArticleService;
import cn.tedu.tmall.admin.content.service.ICategoryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ArticleServiceImpl implements IArticleService {

    @Autowired
    IArticleRepository articleRepository;

    @Override
    public void addNew(ArticleAddNewParm articleAddNewParm){
       Article article=new Article();
       BeanUtils.copyProperties(articleAddNewParm,article);

       //TODO IP地址另外获取
        article.setIp("测试IP地址");

        //TODO 浏览量
        article.setClickCount(0);

        //TODO 评论量
        article.setCommentCount(0);

        //TODO 顶，踩数量
        article.setUpCount(0);
        article.setDownCount(0);

        articleRepository.insert(article);
    }
}
